﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using Runda.CMS.Common.Utility;
using Runda.CMS.Bll;
using Runda.CMS.Common.Entity;

namespace Runda.CMS.Portal.ContractFollowUp
{
    public partial class Holiday_config : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {                      
            Enumerator.DictionaryType contractParm = Enumerator.DictionaryType.Holiday;
            hidentype.Value = System.Convert.ToInt32(contractParm).ToString();
            Data_Bind(contractParm);
        }

        private void Data_Bind(Enumerator.DictionaryType contractParm)
        {
            SysDictionaryBll sysDicBll = new SysDictionaryBll();
            List<SqlDbParameter> parameters = new List<SqlDbParameter>();
            SqlDbParameter parameter = new SqlDbParameter();

            parameter.ColumnType = DbType.Int32;
            parameter.ParameterName = "@Type";
            parameter.ColumnName = "Type";
            parameter.ParameterValue = System.Convert.ToInt32(contractParm);
            parameter.QualificationType = SqlDbParameter.QualificationSymbol.Equal;
            parameters.Add(parameter);
            List<SysDictionaryEntity> sysDicEntitys = sysDicBll.GetAll<SysDictionaryEntity>(parameters,"order by code asc");

            this.RepeaterParms.DataSource = sysDicEntitys;
            this.RepeaterParms.DataBind();

        }

        protected void delete(object sender, EventArgs e)
        {
            if (dicids.Value.Trim() != "")
            {
                string[] dicidsArray = dicids.Value.Trim().Split(new char[] { ';' });
                for (int index = 0; index < dicidsArray.Length; index++)
                {
                    SysDictionaryBll bll = new SysDictionaryBll();
                    SysDictionaryEntity dicEntity = bll.Get<SysDictionaryEntity>(new Guid(dicidsArray[index]));
                    if (dicEntity != null)
                    {
                        bll.LogicDelete(dicEntity);
                    }
                }

                String strtype = this.Request.QueryString["type"];
                hidentype.Value = strtype;
                Enumerator.DictionaryType contractParm = (Enumerator.DictionaryType)System.Convert.ToInt32(strtype);
                Data_Bind(contractParm);
            }
        }
    }
}
